package LeetCode.leetcode104;

class Solution {
    public int maxDepth(TreeNode root) {
        if (root == null)
            return 0;
        int leftDeep = maxDepth(root.left);
        int rightDeep = maxDepth(root.right);
        return Math.max(leftDeep, rightDeep) + 1;
    }

    /**
     * 求当前节点的深度
     *
     * @param node
     * @return
     */
    static int findLength(TreeNode node) {
        if (node == null)
            return 0;
        int leftDeep = findLength(node.left);
        int rightDeep = findLength(node.right);
        return Math.max(leftDeep, rightDeep) + 1;
    }
}
